﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace FigureDraw
{
    public class Border : EffectShape
    {
        public Border(CommonShape shape)
        {
            this.shape = shape;
        }
        public override CommonShape UnEffect()
        {
            return shape;
        }
        public override void DrawToDevice(Form f)
        {
            int red;
            int green;
            int blue;
            int linewid;

            System.Drawing.Point DiemDau;
            System.Drawing.Point DiemCuoi;
            if (this.StorageDevice == null)
            {
                red = this.shape.getRColor();
                green = this.shape.getGColor();
                blue = this.shape.getBColor();
                linewid = this.shape.getLineWidth();

                this.setColor(red, green, blue);
                this.setLineWidth(linewid);

                DiemDau = new System.Drawing.Point(this.shape.BeginPoint.X, this.shape.BeginPoint.Y);
                DiemCuoi = new System.Drawing.Point(this.shape.EndPoint.X, this.shape.EndPoint.Y);
                this.BeginPoint = this.shape.BeginPoint;
                this.EndPoint = this.shape.EndPoint;
                this.StorageDevice = GetStorageDevice();
            }
            else
            {
                red = this.getRColor();
                green = this.getGColor();
                blue = this.getBColor();
                linewid = this.getLineWidth();

                this.shape.setColor(red, green, blue);
                this.shape.setLineWidth(linewid);

                DiemDau = new System.Drawing.Point(this.BeginPoint.X, this.BeginPoint.Y);
                DiemCuoi = new System.Drawing.Point(this.EndPoint.X, this.EndPoint.Y);
                this.shape.BeginPoint = this.BeginPoint;
                this.shape.EndPoint = this.EndPoint;
                this.shape.StorageDevice = GetStorageDevice();
            }





            /*
            this.StorageDevice = GetStorageDevice();
            this.BeginPoint = shape.BeginPoint;
            this.EndPoint = shape.EndPoint;
            this.setColor(shape.getRColor(), shape.getGColor(), shape.getBColor());
            this.setLineWidth(shape.getLineWidth());
            */

            this.shape.DrawToDevice(f);
            this.BeginPoint = shape.BeginPoint;
            this.EndPoint = shape.EndPoint;
            this.StorageDevice = GetStorageDevice();
            this.StorageDevice.drawEllipse(BeginPoint.X, BeginPoint.Y, 5, 5);
            this.StorageDevice.drawEllipse(EndPoint.X, EndPoint.Y, 5, 5);
            this.StorageDevice.drawEllipse(EndPoint.X, BeginPoint.Y, 5, 5);
            this.StorageDevice.drawEllipse(BeginPoint.X, EndPoint.Y, 5, 5);

            this.StorageDevice.drawRect((EndPoint.X + BeginPoint.X) / 2, BeginPoint.Y, 5, 5);
            this.StorageDevice.drawRect((EndPoint.X + BeginPoint.X) / 2, EndPoint.Y, 5, 5);
            this.StorageDevice.drawRect(BeginPoint.X, (BeginPoint.Y + EndPoint.Y) / 2, 5, 5);
            this.StorageDevice.drawRect(EndPoint.X, (BeginPoint.Y + EndPoint.Y) /2, 5, 5);

            // set thong tin
            
        }

        public override string ToString()
        {
            return shape.ToString() + "Border";
        }
    }
}
